package com.ruoyi.util;

import com.ruoyi.config.WebSocketManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TaskScheduler {

    static WebSocketManager webSocketManager = WebSocketManager.INSTANCE;

    @Scheduled(cron = "0 0 */2 * * *") // 每2小时执行一次
    public void executeTask() {
        // 在这里定义定时任务的逻辑
        log.info("这是每2小时执行一次的定时任务");
        log.info("当前WebSocket连接人数为: " + webSocketManager.size());
    }


}
